package com.twu.biblioteca.Models;

import java.util.ArrayList;
import java.util.List;

public class UserManager {

    private List<User> userList;

    public UserManager() {
        userList = new ArrayList<User>();
        User tmp = new User(1111111, "pass123", "Paras Narang", "narangparas@gmail.com", "9566812721");
        userList.add(tmp);
        tmp = new User(1111112, "qwerty", "Superman", "superman@thoughtworks.com", "7742534634");
        userList.add(tmp);
        tmp = new User(1111113, "batman", "Batman", "batman@thoughtworks.com", "8234664543");
        userList.add(tmp);
    }

    public List<User> getUserList() {
        return userList;
    }

    public String getUserMembershipDetails(int username) {
        String message = " User Details Not Found \n";
        for (User user : getUserList()) {
            if (user.getUsername() == username)
                message = user.getUserDetails();
        }
        return message;
    }

    public boolean validateLogin(int username, String password) {
        for (User user : getUserList()) {
            if (user.getUsername() == username)
                if (user.getPassword() == password)
                    return true;
        }
        return false;
    }
}
